﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using MINERP.BLL.Frontier;
using MINERP.MODEL.Frontier;

namespace MINERP.Frontier
{
    public delegate void ShowQueryResultHander(List<OrderInfo_Info> list);
    public partial class FrmQuery : Form
    {
        private OrderInfoBLL _bll = new OrderInfoBLL();
        public ShowQueryResultHander showQueryResultHander;
        public int printerId = 0;
        private string ctmName;
        private  string productName;
        private  DateTime startTime;
        private DateTime endTime;
        private int orderProductId =0;
        
        public FrmQuery()
        {
            InitializeComponent();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtCtmName.Text.Trim()))
            {
                ctmName = txtCtmName.Text.Trim();
            }
            if (!string.IsNullOrEmpty(txtOrderProductCode.Text.Trim()))
            {
                orderProductId =Convert.ToInt32( txtOrderProductCode.Text.Trim());
            }
            if (!string.IsNullOrEmpty(txtProductName.Text.Trim()))
            {
                productName = txtProductName.Text.Trim();
            }
            if (!string.IsNullOrEmpty(dtStartTime.Text.Trim()))
            {
                startTime = dtStartTime.DateTime;
            }
            if (!string.IsNullOrEmpty(dtEndTime.Text.Trim()))
            {
                endTime = dtEndTime.DateTime;
            }
            if ( string.IsNullOrEmpty(ctmName) && string.IsNullOrEmpty(productName) && string.IsNullOrEmpty(dtStartTime.Text) && string.IsNullOrEmpty(dtEndTime.Text)&& orderProductId == 0)
            {
                MessageBox.Show("请最少输入一个查询条件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                List<OrderInfo_Info> OrderInfolist = _bll.GetOrderInfoListByCondition(printerId, ctmName, productName, startTime, endTime, orderProductId);
                showQueryResultHander.Invoke(OrderInfolist);
                this.Close();
            }
            
        }
    }
}
